package com.cqut.ktpspring.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cqut.ktpspring.controller.CourseMemberController;
import com.cqut.ktpspring.pojo.CourseMember;
import com.cqut.ktpspring.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CourseMemberMapper extends BaseMapper<CourseMember> {
    @Insert("insert into course_member(cno,member) values (#{cno},#{userId})")
    void add(String cno, String userId);

    void delete(String cno, List<String> members);

    @Select("select member from course_member where cno=#{cno} and status!=2")
    List<String> getCourseMembers(String cno);


    List<String> getCourse(String userId);


    @Select("select count(*) from course_member where cno = #{cno}")
    int getMemberCount(String cno);


    void changeAllStatus(String cno, int status);

    @Select("select * from course_member where cno=#{cno} and member=#{userId}")
    CourseMember getCourseMember(String cno, String userId);

    //新增学生加课调用
    void updateMember(String cno);

    //学生退课调用
    void minusMember(String cno);

}


